package com.woniuxy.controller;

import com.woniuxy.entity.Comment;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.CommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 杜昊男  <br/>
 * Date: 2022/3/12:10:14  <br/>
 * Description:
 */
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    @ApiOperation(value = "查询评论")
    @PostMapping("/findComments")
    public ResponseEntity findComments(@RequestBody Comment comment) {
        return commentService.findComments(comment);
    }

    @ApiOperation(value = "创建评论")
    @PostMapping("/CreateComments")
    public ResponseEntity CreateComments(@RequestBody Comment comment) {
        return commentService.createComments(comment);
    }

    @ApiOperation(value = "评论点赞")
    @PutMapping("/giveLike/{commentid}/{isLiked}")
    public ResponseEntity updateLike(@PathVariable("commentid") int commentid, @PathVariable("isLiked") int isLiked) {
        return commentService.updateLike(commentid, isLiked);
    }
}

